random-choice algorithm